GtkButton: tighten code a bit
authorMatthias Clasen <mclasen@redhat.com>
Fri, 23 May 2014 02:45:56 +0000 (22:45 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 23 May 2014 03:15:08 +0000 (23:15 -0400)
Make it so we only use GtkMisc in one place.

gtk/gtkbutton.c

index fe1549928814b6bd55fae710406d986b923c6321..239c512513aba8f0959dca03cdd246467415ec5a 100644 (file)
@@ -684,29 +684,12 @@ maybe_set_alignment (GtkButton *button,
 {
   GtkButtonPrivate *priv = button->priv;
 
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  if (GTK_IS_MISC (widget))
-    {
-      GtkMisc *misc = GTK_MISC (widget);
-
-      if (priv->align_set)
-       gtk_misc_set_alignment (misc, priv->xalign, priv->yalign);
-    }
-  else if (GTK_IS_ALIGNMENT (widget))
-    {
-      GtkAlignment *alignment = GTK_ALIGNMENT (widget);
-      gfloat xscale, yscale;
-
-      g_object_get (alignment,
-                    "xscale", &xscale,
-                    "yscale", &yscale,
-                    NULL);
+  if (!priv->align_set)
+    return;
 
-      if (priv->align_set)
-        gtk_alignment_set (alignment,
-                           priv->xalign, priv->yalign,
-                           xscale, yscale);
-    }
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  if (GTK_IS_MISC (widget) || GTK_IS_ALIGNMENT (widget))
+    g_object_set (widget, "xalign", priv->xalign, "yalign", priv->yalign, NULL);
 G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
@@ -1297,10 +1280,7 @@ gtk_button_construct_child (GtkButton *button)
 
   gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
 
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  if (priv->align_set)
-    gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
-G_GNUC_END_IGNORE_DEPRECATIONS
+  maybe_set_alignment (button, label);
 
   gtk_widget_show (label);
   gtk_container_add (GTK_CONTAINER (button), label);